package com.css.apps.base.menu.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import com.css.core.model.tree.TreeType;
import com.css.db.query.QueryCache;

import net.sf.json.JSONObject;

@SuppressWarnings("serial")
public class SMenu implements Serializable, TreeType {

	private String menuId;
	private String funcId;
	private String menuName;
	private String parentId;
	private String url;
	private String openFlag;
	private String sysId;
	private Integer orderNum;
	private String icon;
	private Date editTime;

	public SMenu() {
		super();
	}

	public String getMenuId() {
		return menuId;
	}

	public void setMenuId(String menuId) {
		this.menuId = menuId;
	}

	public String getFuncId() {
		return funcId;
	}

	public void setFuncId(String funcId) {
		this.funcId = funcId;
	}

	public String getMenuName() {
		return menuName;
	}

	public void setMenuName(String menuName) {
		this.menuName = menuName;
	}

	public String getParentId() {
		return parentId;
	}

	public void setParentId(String parentId) {
		this.parentId = parentId;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getOpenFlag() {
		return openFlag;
	}

	public void setOpenFlag(String openFlag) {
		this.openFlag = openFlag;
	}

	public String getSysId() {
		return sysId;
	}

	public void setSysId(String sysId) {
		this.sysId = sysId;
	}

	public Integer getOrderNum() {
		return orderNum;
	}

	public void setOrderNum(Integer orderNum) {
		this.orderNum = orderNum;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public JSONObject toJson() {
		return new JSONObject().element("menuId", menuId)
				.element("funcId", funcId).element("menuName", menuName)
				.element("parentId", parentId).element("url", url)
				.element("orderNum", orderNum).element("openFlag", openFlag)
				.element("sysId", sysId).element("icon", icon);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<String> getTreeList() {
		return new QueryCache("select a.menuId from SMenu a order by a.orderNum").list();
	}

	@Override
	public List<String> getTreeList(String key) {
		return getTreeList();
	}

	@Override
	public String getNodeId() {
		return this.menuId;
	}

	@Override
	public String getNodeParentId() {
		return this.parentId;
	}

	@Override
	public String getNodeName() {
		return this.menuName;
	}

	@Override
	public Serializable getSerializeId() {
		return this.menuId;
	}

	@Override
	public String getRootSerializeId() {
		return "0";
	}

	public Date getEditTime() {
		return editTime;
	}

	public void setEditTime(Date editTime) {
		this.editTime = editTime;
	}
	
}
